home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 July: Mac OS SDK / Dev.CD Jul 00 SDK2.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / WorldScript.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  9.4 KB  |  350 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        WorldScript.h
  3.  
  4.      Contains:    WorldScript I Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1994-1999 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __WORLDSCRIPT__
  18. #define __WORLDSCRIPT__
  19.  
  20. #ifndef __MACTYPES__
  21.     #include <MacTypes.h>
  22. #endif
  23.  
  24. #ifndef __TRAPS__
  25.     #include <Traps.h>
  26. #endif
  27.  
  28. #ifndef __QUICKDRAWTEXT__
  29.     #include <QuickdrawText.h>
  30. #endif
  31.  
  32.  
  33.  
  34.  
  35. #if PRAGMA_ONCE
  36. #pragma once
  37. #endif
  38.  
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42.  
  43. #if PRAGMA_IMPORT
  44. #pragma import on
  45. #endif
  46.  
  47. #if PRAGMA_STRUCT_ALIGN
  48.     #pragma options align=mac68k
  49. #elif PRAGMA_STRUCT_PACKPUSH
  50.     #pragma pack(push, 2)
  51. #elif PRAGMA_STRUCT_PACK
  52.     #pragma pack(2)
  53. #endif
  54.  
  55. typedef UInt16                             WSIOffset;
  56. typedef UInt8                             WSIByteCount;
  57. typedef UInt8                             WSIByteIndex;
  58. /* offset from start of sub-table to row in state table */
  59. typedef UInt16                             WSIStateOffset;
  60. typedef UInt32                             WSITableOffset;
  61. typedef UInt16                             WSISubtableOffset;
  62. typedef UInt16                             WSIGlyphcode;
  63. typedef UInt32                             WSITableIdentifiers;
  64. enum {
  65.     kScriptSettingsTag            = FOUR_CHAR_CODE('info'),
  66.     kMetamorphosisTag            = FOUR_CHAR_CODE('mort'),
  67.     kGlyphExpansionTag            = FOUR_CHAR_CODE('g2g#'),
  68.     kPropertiesTag                = FOUR_CHAR_CODE('prop'),
  69.     kJustificationTag            = FOUR_CHAR_CODE('kash'),
  70.     kCharToGlyphTag                = FOUR_CHAR_CODE('cmap'),
  71.     kGlyphToCharTag                = FOUR_CHAR_CODE('pamc'),
  72.     kFindScriptRunTag            = FOUR_CHAR_CODE('fstb')
  73. };
  74.  
  75.  
  76.  
  77. /****             L O O K U P    T A B L E    T Y P E S        ****/
  78. enum {
  79.     WSILookupSimpleArray        = 0,                            /* a simple array indexed by glyph code */
  80.     WSILookupSegmentSingle        = 2,                            /* segment mapping to single value */
  81.     WSILookupSegmentArray        = 4,                            /* segment mapping to lookup array */
  82.     WSILookupSingleTable        = 6,                            /* sorted list of glyph, value pairs */
  83.     WSILookupTrimmedArray        = 8                                /* a simple trimmed array indexed by glyph code */
  84. };
  85.  
  86. typedef unsigned short                     WSILookupTableFormat;
  87. typedef unsigned short                     WSILookupValue;
  88. /* An offset from the beginning of the lookup table */
  89. typedef unsigned short                     WSILookupOffset;
  90. /*    FORMAT SPECIFIC DEFINITIONS */
  91. /*
  92.         lookupSimpleArray:
  93.         
  94.         This is a simple array which maps all glyphs in the font
  95.         to lookup values.
  96.     */
  97.  
  98. struct WSILookupArrayHeader {
  99.     WSILookupValue                     lookupValues[1];            /* The array of values indexed by glyph code */
  100. };
  101. typedef struct WSILookupArrayHeader        WSILookupArrayHeader;
  102. /*
  103.         lookupTrimmedArray:
  104.         
  105.         This is a single trimmed array which maps a single range
  106.         of glyhs in the font to lookup values.
  107.     */
  108.  
  109. struct WSILookupTrimmedArrayHeader {
  110.     WSIGlyphcode                     firstGlyph;
  111.     WSIGlyphcode                     limitGlyph;
  112.     WSILookupValue                     valueArray[1];
  113. };
  114. typedef struct WSILookupTrimmedArrayHeader WSILookupTrimmedArrayHeader;
  115. /* The format specific part of the subtable header */
  116.  
  117. union WSILookupFormatSpecificHeader {
  118.     WSILookupArrayHeader             simpleArray;                /* rename lookupArray as simpleArray <9> */
  119.     WSILookupTrimmedArrayHeader     trimmedArray;
  120. };
  121. typedef union WSILookupFormatSpecificHeader WSILookupFormatSpecificHeader;
  122. /* The overall subtable header */
  123.  
  124. struct WSILookupTableHeader {
  125.     WSILookupTableFormat             format;                        /* table format */
  126.     WSILookupFormatSpecificHeader     fsHeader;                    /* format specific header */
  127. };
  128. typedef struct WSILookupTableHeader        WSILookupTableHeader;
  129.  
  130. /****        G L Y P H    E X P A N S I O N    ****/
  131. enum {
  132.                                                                 /* fixed 1.0 */
  133.     kCurrentGlyphExpansionVersion = 0x00010000
  134. };
  135.  
  136.  
  137. typedef unsigned short                     GlyphExpansionFormats;
  138. enum {
  139.     GlyphExpansionLookupFormat    = 1,
  140.     GlyphExpansionContextualFormat = 2
  141. };
  142.  
  143.  
  144. struct ExpandedGlyphCluster {
  145.     WSIByteCount                     numGlyphs;
  146.     WSIByteIndex                     bestGlyph;
  147.     WSIGlyphcode                     glyphs[1];
  148. };
  149. typedef struct ExpandedGlyphCluster        ExpandedGlyphCluster;
  150.  
  151. struct ExpandedGlyphOffset {
  152.     WSIGlyphcode                     glyph;
  153.     WSIOffset                         offset;                        /* offset to ExpandedGlyphCluster */
  154. };
  155. typedef struct ExpandedGlyphOffset        ExpandedGlyphOffset;
  156.  
  157. struct GlyphExpansionStateTable {
  158.     WSISubtableOffset                 stateTableOffset;
  159.     WSISubtableOffset                 classTableOffset;
  160.     WSISubtableOffset                 actionTableOffset;            /* state, class and actions tables follow here... */
  161. };
  162. typedef struct GlyphExpansionStateTable    GlyphExpansionStateTable;
  163.  
  164. struct GlyphExpansionTable {
  165.     Fixed                             version;
  166.     short                             format;
  167.     short                             expansionNumer;
  168.     short                             expansionDenom;                /* num/denom ratio for expansion <2> */
  169.  
  170.     union {
  171.         GlyphExpansionStateTable         stateTable;
  172.         WSILookupTableHeader             lookup;                    /* expanded glyph clusters follow here... */
  173.     }                                 table;
  174. };
  175. typedef struct GlyphExpansionTable        GlyphExpansionTable;
  176.  
  177. /* Glyph-to-Character constants and types  */
  178. enum {
  179.     kCurrentGlyphToCharVersion    = 0x00010100
  180. };
  181.  
  182.  
  183. typedef unsigned short                     GlyphToCharLookupFormats;
  184. enum {
  185.     kGlyphToCharLookup8Format    = 1,
  186.     kGlyphToCharLookup16Format    = 2,
  187.     kGlyphToCharLookup32Format    = 3
  188. };
  189.  
  190. typedef UInt8                             GlyphToCharFontIndex;
  191. typedef UInt8                             QDGlyphcode;
  192.  
  193. struct GlyphToCharActionTable {
  194.     WSISubtableOffset                 fontNameOffset;                /* offset relative to this table */
  195.     WSILookupTableHeader             actions;                    /* only support lookupSimpleArray format for now */
  196. };
  197. typedef struct GlyphToCharActionTable    GlyphToCharActionTable;
  198.  
  199. struct GlyphToCharActionHeader {
  200.     short                             numTables;                    /* 0..n */
  201.     WSISubtableOffset                 offsets[1];                    /* offsets from start of action table header */
  202. };
  203. typedef struct GlyphToCharActionHeader    GlyphToCharActionHeader;
  204.  
  205. struct GlyphToCharHeader {
  206.     Fixed                             version;
  207.  
  208.     WSISubtableOffset                 actionOffset;                /* offset to GlyphToCharActionHeader */
  209.  
  210.     short                             format;                        /* size of font mask */
  211.     WSILookupTableHeader             mappingTable;
  212. };
  213. typedef struct GlyphToCharHeader        GlyphToCharHeader;
  214.  
  215. /* JUSTIFICATION TYPES
  216.     WorldScript supports justification of text using insertion. The justification
  217.     table specifies a insertion string to insert between 2 specified glyphs.
  218.     Each combination of inter-glyph boundary can be assigned a justification priority,
  219.     the higher the priority the more justification strings inserted at that position.
  220.     
  221.     The priorities for each inter-glyph boundary are specified by the justification table's
  222.     state table.
  223.     
  224.     Special handling is done for scripts which use spaces to justify, because the width of 
  225.     a space varies depending on the setting of SpaceExtra. This is why the number of spaces
  226.     per inserting string is specified in the justification table.
  227.  
  228. */
  229. enum {
  230.                                                                 /* 1.0 not supported */
  231.     kCurrentJustificationVersion = 0x0200
  232. };
  233.  
  234. enum {
  235.     kJustificationStateTableFormat = 1
  236. };
  237.  
  238. enum {
  239.                                                                 /* WSI's internal limitation <12> */
  240.     kMaxJustificationStringLength = 13
  241. };
  242.  
  243.  
  244. typedef UInt8                             WSIJustificationPriority;
  245. enum {
  246.     WSIJustificationSetMarkMask    = 0x80
  247. };
  248.  
  249.  
  250. struct WSIJustificationStateEntry {
  251.     WSIJustificationPriority         markPriority;                /* non-zero priorities means insertion */
  252.     WSIJustificationPriority         priority;
  253.     WSIStateOffset                     newState;
  254. };
  255. typedef struct WSIJustificationStateEntry WSIJustificationStateEntry;
  256.  
  257. typedef unsigned short                     WSIJustificationClasses;
  258. enum {
  259.     wsiJustEndOfLineClass        = 0,
  260.     wsiJustEndOfRunClass        = 1,
  261.     wsiJustDeletedGlyphClass    = 2,
  262.     wsiJustUserDefinedClass        = 3
  263. };
  264.  
  265. typedef unsigned short                     WSIJustificationStates;
  266. enum {
  267.     wsiStartOfLineState            = 0,                            /* pre-defined states */
  268.     wsiStartOfRunState            = 1,
  269.     wsiUserDefinedState            = 2
  270. };
  271.  
  272. /* pre-multiplied: class# * sizeof(WSIJustificationStateEntry) */
  273. typedef UInt8                             WSIJustificationClassOffset;
  274.  
  275. struct WSIJustificationStateTable {
  276.     short                             maxPriorities;
  277.     unsigned short                     rowWidth;                    /* width of a state table row in bytes */
  278.     short                             classTableOffset;
  279.     short                             stateTableOffset;
  280. };
  281. typedef struct WSIJustificationStateTable WSIJustificationStateTable;
  282. /*
  283.             Last two fields of above structure - someday?
  284.             WSIJustificationClassOffset    classes[up to 64 classes supported];
  285.             WSIJustificationStateEntry    states[up to your heart's desire];
  286.         */
  287.  
  288. struct WSIJustificationHeader {
  289.     short                             version;
  290.     short                             format;
  291.  
  292.     Point                             scaling;                    /* numer/denom scaling of priority weights <7> */
  293.  
  294.     unsigned short                     spacesPerInsertion;            /* # of $20 chars in justification insertion string <12> */
  295.     unsigned short                     justStringOffset;            /* offset to justification string */
  296.  
  297.  
  298.     WSIJustificationStateTable         stateTable;                    /* long-aligned boundary aligned w/ spacesPerInsertion field - justification string follows */
  299. };
  300. typedef struct WSIJustificationHeader    WSIJustificationHeader;
  301.  
  302. /* Line Layout's Property table version <11> */
  303. enum {
  304.                                                                 /* v1.0 */
  305.     currentPropsTableVersion    = 0x00010000
  306. };
  307.  
  308. enum {
  309.                                                                 /* version is octal 0100 or hex 0x40 (#64) */
  310.     kCharToGlyphCurrentVersion    = 0x40
  311. };
  312.  
  313. /* pass as priorityWeight to JustifyWSILayout to use script's current just setting */
  314. enum {
  315.     kScriptsDefaultJustWeight    = -1
  316. };
  317.  
  318.  
  319. /* feature selectors used in FindScriptRun and itl5 configuration tables <9> */
  320.  
  321. typedef UInt16                             WSIFeatureType;
  322. typedef UInt16                             WSIFeatureSelector;
  323.  
  324. struct WSIFeature {
  325.     WSIFeatureType                     featureType;
  326.     WSIFeatureSelector                 featureSelector;
  327. };
  328. typedef struct WSIFeature                WSIFeature;
  329.  
  330. #if PRAGMA_STRUCT_ALIGN
  331.     #pragma options align=reset
  332. #elif PRAGMA_STRUCT_PACKPUSH
  333.     #pragma pack(pop)
  334. #elif PRAGMA_STRUCT_PACK
  335.     #pragma pack()
  336. #endif
  337.  
  338. #ifdef PRAGMA_IMPORT_OFF
  339. #pragma import off
  340. #elif PRAGMA_IMPORT
  341. #pragma import reset
  342. #endif
  343.  
  344. #ifdef __cplusplus
  345. }
  346. #endif
  347.  
  348. #endif /* __WORLDSCRIPT__ */
  349.  
  350.